<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
    x:Class="OpenLS.Chart.UI.ValueAxisResources"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:chart="http://schemas.Kherty.com/office/2007/chart" 
    xmlns:drawing2="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
    xmlns:chartui="clr-namespace:OpenLS.Chart.UI"
    xmlns:Internals="clr-namespace:OpenLS.Chart.UI.Internals"
>
    <ResourceDictionary.MergedDictionaries>
        <chartui:ChartLineResources/>
        <chartui:TitleResources/>
        <chartui:UnitResources/>
        <drawing2:TextResources></drawing2:TextResources>

    </ResourceDictionary.MergedDictionaries>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="NumericValueLabelTemplate">
        <TextBlock Margin="3 0 6 0" Name="tb" Style="{x:Static chartui:NumericValueResources.NumericValueLabelStyle}">
        </TextBlock>
    </DataTemplate>
    <DataTemplate DataType="{x:Type chart:NumericValue}" x:Key="NumericValueTickTemplate">
        <Line Stroke="Black" StrokeThickness="1" Name="l" />
        <DataTemplate.Triggers>
            
            <DataTrigger Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="{x:Static chart:AxisPosition.Right}">
                <Setter TargetName="l" Property="HorizontalAlignment" Value="Left"/>
            </DataTrigger>
            <DataTrigger Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="{x:Static chart:AxisPosition.Left}">
                <Setter TargetName="l" Property="HorizontalAlignment" Value="Right"/>
            </DataTrigger>
            <DataTrigger Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="{x:Static chart:AxisPosition.Top}">
                <Setter TargetName="l" Property="VerticalAlignment" Value="Bottom"/>
            </DataTrigger>
            <DataTrigger Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="{x:Static chart:AxisPosition.Bottom}">
                <Setter TargetName="l" Property="VerticalAlignment" Value="Top"/>
            </DataTrigger>
            
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Bottom"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Cross}"/>
                </MultiDataTrigger.Conditions>
                <Setter Property="Y2" TargetName="l"  Value="6"/>
                <Setter  TargetName="l" Property="Margin" Value="0 -3 0 0"/>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Bottom"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Inside}"/>
                </MultiDataTrigger.Conditions>
                <Setter  TargetName="l" Property="Y2" Value="3"/>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Bottom"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Outside}"/>
                </MultiDataTrigger.Conditions>
                <Setter  TargetName="l" Property="Y2" Value="3"/>
                <Setter  TargetName="l" Property="Margin" Value="0 -3 0 0"/>
            </MultiDataTrigger>

            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Top"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Cross}"/>
                </MultiDataTrigger.Conditions>
                <Setter TargetName="l" Property="Y2" Value="6"/>
                <Setter TargetName="l" Property="Margin" Value="0 0 0 -3"/>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Top"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Outside}"/>
                </MultiDataTrigger.Conditions>
                <Setter TargetName="l" Property="Y2" Value="3"/>
                <Setter TargetName="l" Property="Margin" Value="0 0 0 -3"/>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Top"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Inside}"/>
                </MultiDataTrigger.Conditions>
                <Setter TargetName="l" Property="Y2" Value="3"/>
            </MultiDataTrigger>
            
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Left"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Cross}"/>
                </MultiDataTrigger.Conditions>
                <Setter TargetName="l" Property="X2" Value="6"/>
                <Setter TargetName="l" Property="Margin" Value="0 0 -3 0"/>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Left"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Outside}"/>
                </MultiDataTrigger.Conditions>
                <Setter TargetName="l" Property="X2" Value="3"/>
                <Setter TargetName="l" Property="Margin" Value="0 0 -3 0"/>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Left"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Inside}"/>
                </MultiDataTrigger.Conditions>
                <Setter  TargetName="l" Property="X2" Value="3"/>
            </MultiDataTrigger>
            
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Right"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Cross}"/>
                </MultiDataTrigger.Conditions>
                <Setter TargetName="l" Property="X2" Value="6"/>
                <Setter TargetName="l" Property="Margin" Value="-3 0 0 0"/>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Right"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Outside}"/>
                </MultiDataTrigger.Conditions>
                <Setter TargetName="l" Property="X2" Value="3"/>
                <Setter TargetName="l" Property="Margin" Value="-3 0 0 0"/>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ElementName=l, Path=(chartui:AxisElement.AxisPosition)}" Value="Right"/>
                    <Condition Binding ="{Binding ElementName=l, Path=(chartui:AxisElement.TickMark)}" Value="{x:Static chart:TickMark.Inside}"/>
                </MultiDataTrigger.Conditions>
                <Setter TargetName="l" Property="X2" Value="3"/>
            </MultiDataTrigger>
            
        </DataTemplate.Triggers>
    </DataTemplate>
    <Style TargetType="{x:Type ItemsControl}" x:Key="ValueAxisControlStyle">
        <Setter Property="Focusable" Value="True"/>
        <EventSetter Event="MouseDown" Handler="onMouseDown"/>
        <Setter Property="chartui:AxisElement.MajorStep">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMajorStepConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsSource">
            <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToValuesConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.MajorStep)"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property ="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <chartui:ValueAxisPanel
                        x:Name="ns" 
                        DataContext="{Binding}"
                        Minimum ="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:AxisElement.Minimum)}" 
                        Maximum ="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:AxisElement.Maximum)}" 
                        ValueAxisOrientation ="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:AxisElement.AxisOrientation)}" 
                        Orientation="{Binding Path=(chartui:AxisElement.Orientation), RelativeSource={RelativeSource Self}}"
              />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property ="ItemContainerStyle">
            <Setter.Value>
                <Style>
                    <Setter Property="chartui:ValueAxisPanel.Value" Value="{Binding Value}"/>
                </Style>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ItemsControl}" x:Key="ValueAxisLabelsStyle" BasedOn="{StaticResource ValueAxisControlStyle}">
        <Setter Property ="ItemTemplate" Value="{StaticResource NumericValueLabelTemplate}">
        </Setter>
    </Style>
    <Style TargetType="{x:Type ItemsControl}" x:Key="ValueAxisTicksStyle" BasedOn="{StaticResource ValueAxisControlStyle}">
        <Setter Property ="ItemTemplate" Value="{StaticResource NumericValueTickTemplate}">
        </Setter>
    </Style>
    <DataTemplate DataType="{x:Type chart:ValueAxis}" >
        <DockPanel Name="grid" chartui:AxisElement.Axis="{Binding}">
            <Line Name="line" Style="{x:Static chartui:ShapedObjectResources.ShapedObjectStyle}" StrokeThickness="{Binding ShapeProperties.LineProperties.Width, FallbackValue=1}"></Line>
            <Grid Name="title" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Grid.CommandBindings>
                    <CommandBinding Command="{x:Static ApplicationCommands.Delete}" Executed="onDeleteTitle"></CommandBinding>
                </Grid.CommandBindings>
                <ContentPresenter  Content="{Binding Title.Text.Content}" 
                               HorizontalAlignment="Center" VerticalAlignment="Center"
                               >
                </ContentPresenter>

            </Grid>


            <ContentPresenter Content="{Binding DisplayUnits}" Name="displayUnits"/>
            <Grid>
                <ItemsControl Style="{StaticResource ValueAxisTicksStyle}" Grid.Column="0" Grid.Row="0"
                          chartui:AxisElement.TickMark="{Binding MajorTickMark}"
                          chartui:AxisElement.AxisPosition="{Binding Position}"
                      chartui:AxisElement.Axis="{Binding}">
                    <ItemsControl.CommandBindings>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.FormatAxis}" Executed="onFormatAxis"/>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.AddTitle}" Executed="onAddTitle" CanExecute="onCanAddTitle" />
                        <CommandBinding Command="{x:Static ApplicationCommands.Delete}" Executed="onDelete"/>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.AddMajorGridLines}" Executed="onAddMajorGridLines" CanExecute="onCanAddMajorGridLines"/>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.AddMinorGridLines}" Executed="onAddMinorGridLines" CanExecute="onCanAddMinorGridLines"/>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.FormatMajorGridLines}" Executed="onFormatMajorGridLines" CanExecute="onCanFormatMajorGridLines"/>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.FormatMinorGridLines}" Executed="onFormatMinorGridLines" CanExecute="onCanFormatMinorGridLines"/>
                    </ItemsControl.CommandBindings>
                    <ItemsControl.ContextMenu>
                        <ContextMenu>
                            <MenuItem Command="{x:Static ApplicationCommands.Delete}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.AddTitle}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <Separator/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.AddMajorGridLines}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.AddMinorGridLines}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.FormatMajorGridLines}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.FormatMinorGridLines}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.FormatAxis}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                        </ContextMenu>
                    </ItemsControl.ContextMenu>
                </ItemsControl>
                <ItemsControl Name="ic1" Style="{StaticResource ValueAxisLabelsStyle}" Grid.Column="0" Grid.Row="0"
                      chartui:AxisElement.Axis="{Binding}"
                          drawing2:DrawingElement.ShapeProperties="{Binding ShapeProperties}"
                            
                          chartui:AxisElement.TickLabelPosition="{Binding Path=TickLabelPosition}"
                          >
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <chartui:ValueAxisPanel
                        x:Name="ns" 
                        DataContext="{Binding}"
                        Minimum ="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:AxisElement.Minimum)}" 
                        Maximum ="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:AxisElement.Maximum)}" 
                        ValueAxisOrientation ="{Binding Orientation}" 
                                Orientation="{Binding Path=(chartui:AxisElement.Orientation), RelativeSource={RelativeSource Self}}"
                        TickLabelPosition ="{Binding TickLabelPosition}" />
                        </ItemsPanelTemplate>

                    </ItemsControl.ItemsPanel>

                    <ItemsControl.CommandBindings>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.FormatAxis}" Executed="onFormatAxis"/>
                        <CommandBinding Command="{x:Static ApplicationCommands.Delete}" Executed="onDelete"/>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.AddTitle}" Executed="onAddTitle" CanExecute="onCanAddTitle" />
                        <CommandBinding Command="{x:Static chartui:ChartCommands.AddMajorGridLines}" Executed="onAddMajorGridLines" CanExecute="onCanAddMajorGridLines"/>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.AddMinorGridLines}" Executed="onAddMinorGridLines" CanExecute="onCanAddMinorGridLines"/>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.FormatMajorGridLines}" Executed="onFormatMajorGridLines" CanExecute="onCanFormatMajorGridLines"/>
                        <CommandBinding Command="{x:Static chartui:ChartCommands.FormatMinorGridLines}" Executed="onFormatMinorGridLines" CanExecute="onCanFormatMinorGridLines"/>
                    </ItemsControl.CommandBindings>
                    <ItemsControl.ContextMenu>
                        <ContextMenu>
                            <MenuItem Command="{x:Static ApplicationCommands.Delete}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.AddTitle}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <Separator/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.AddMajorGridLines}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.AddMinorGridLines}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.FormatMajorGridLines}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.FormatMinorGridLines}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                            <MenuItem Command="{x:Static chartui:ChartCommands.FormatAxis}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                        </ContextMenu>
                    </ItemsControl.ContextMenu>
                </ItemsControl>
            </Grid>
            
        </DockPanel>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=(chartui:AxisElement.Orientation), ElementName=grid}" Value="{x:Static Orientation.Horizontal}">
                <Setter TargetName="displayUnits" Property="Grid.Row" Value="1"/>
                <Setter TargetName="displayUnits" Property="Grid.Column" Value="1"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Position}" Value="Top">
                <Setter TargetName="line" Property="DockPanel.Dock" Value="Bottom"/>
                <Setter TargetName="line" Property="X2" Value="{Binding ElementName=grid, Path=ActualWidth}"/>
                <Setter TargetName="displayUnits" Property="DockPanel.Dock" Value="Top"/>
                <Setter TargetName="title" Property="DockPanel.Dock" Value="Top"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Position}" Value="Bottom">
                    <Setter TargetName="line" Property="DockPanel.Dock" Value="Top"/>
                <Setter TargetName="displayUnits" Property="DockPanel.Dock" Value="Bottom"/>
                <Setter TargetName="title" Property="DockPanel.Dock" Value="Bottom"/>
                <Setter TargetName="line" Property="X2" Value="{Binding ElementName=grid, Path=ActualWidth}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Position}" Value="Left">
                    <Setter TargetName="line" Property="DockPanel.Dock" Value="Right"/>
                <Setter TargetName="displayUnits" Property="DockPanel.Dock" Value="Left"/>
                <Setter TargetName="title" Property="DockPanel.Dock" Value="Left"/>
                <Setter TargetName="line" Property="Y2" Value="{Binding ElementName=grid, Path=ActualHeight}"/>
                <Setter TargetName="line" Property="Grid.Column" Value="1"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Position}" Value="Right">
                    <Setter TargetName="line" Property="DockPanel.Dock" Value="Left"/>
                <Setter TargetName="displayUnits" Property="DockPanel.Dock" Value="Right"/>
                <Setter TargetName="title" Property="DockPanel.Dock" Value="Right"/>
                <Setter TargetName="line" Property="Y2" Value="{Binding ElementName=grid, Path=ActualHeight}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding IsVisible}" Value="False">
                <Setter TargetName="grid" Property="Visibility" Value="Collapsed"></Setter>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

</ResourceDictionary>